<div class="flex flex-col border-l border-1 border-slate-800 pl-3">
    <div class="py-2 flex justify-between">
        <div class="text-2xl font-bold text-slate-100"><%= @projects |> Page.title("project") %></div>
        <%= render AzimuttWeb.PartialsView, "_page_search.html", page: @projects %>
    </div>

    <div class="align-middle shadow sm:rounded-sm">
        <table class="w-full text-left">
            <thead class="text-gray-100 bg-slate-800 text-xs font-semibold">
                <tr>
                    <th class="group p-1" scope="col">
                        Created at
                        <%= render AzimuttWeb.PartialsView, "_page_sort.html", page: @projects, key: "created_at" %>
                    </th>
                    <th class="group p-1" scope="col">
                        Name
                        <%= render AzimuttWeb.PartialsView, "_page_sort.html", page: @projects, key: "name" %>
                    </th>
                    <th class="p-1" scope="col">
                        <span class="group inline-block w-8 text-red-300" title="nb_sources">
                            S
                            <%= render AzimuttWeb.PartialsView, "_page_sort.html", page: @projects, key: "nb_sources", default: "down" %>
                        </span> /
                        <span class="group inline-block w-8 text-amber-300" title="nb_tables">
                            T
                            <%= render AzimuttWeb.PartialsView, "_page_sort.html", page: @projects, key: "nb_tables", default: "down" %>
                        </span> /
                        <span class="group inline-block w-8 text-lime-300" title="nb_layouts">
                            L
                            <%= render AzimuttWeb.PartialsView, "_page_sort.html", page: @projects, key: "nb_layouts", default: "down" %>
                        </span> /
                        <span class="group inline-block w-8 text-emerald-300" title="nb_comments">
                            C
                            <%= render AzimuttWeb.PartialsView, "_page_sort.html", page: @projects, key: "nb_comments", default: "down" %>
                        </span> /
                        <span class="group inline-block w-8 text-cyan-300" title="nb_notes">
                            N
                            <%= render AzimuttWeb.PartialsView, "_page_sort.html", page: @projects, key: "nb_notes", default: "down" %>
                        </span> /
                        <span class="group inline-block w-8 text-blue-300" title="nb_memos">
                            M
                            <%= render AzimuttWeb.PartialsView, "_page_sort.html", page: @projects, key: "nb_memos", default: "down" %>
                        </span>
                    </th>
                    <th class="p-1" scope="col">Organization</th>
                    <th class="p-1" scope="col">Storage</th>
                    <th class="p-1" scope="col">Public</th>
                    <th class="group p-1" scope="col">
                        Last update
                        <%= render AzimuttWeb.PartialsView, "_page_sort.html", page: @projects, key: "updated_at", default: "down" %>
                    </th>
                </tr>
            </thead>
            <tbody class="divide-y divide-slate-800 text-slate-500 bg-slate-900">
                <%= for project <- @projects.items do %>
                    <tr class="text-xs whitespace-nowrap hover:bg-slate-800 hover:text-slate-300">
                        <td class="group p-1">
                            <%= format_datetime(project.created_at) %>
                            <%= render AzimuttWeb.PartialsView, "_page_filter.html", page: @projects, key: "created_at", value: format_date_filter(project.created_at) %>
                        </td>
                        <td class="p-1" title={project.description}><%= link project.name, to: Routes.admin_project_path(@conn, :show, project), class: "underline" %></td>
                        <td class="p-1">
                            <span class="inline-block w-8 text-red-300" title="nb_sources"><%= project.nb_sources %></span> /
                            <span class="inline-block w-8 text-amber-300" title="nb_tables"><%= project.nb_tables %></span> /
                            <span class="inline-block w-8 text-lime-300" title="nb_layouts"><%= project.nb_layouts %></span> /
                            <span class="inline-block w-8 text-emerald-300" title="nb_comments"><%= project.nb_comments %></span> /
                            <span class="inline-block w-8 text-cyan-300" title="nb_notes"><%= project.nb_notes %></span> /
                            <span class="inline-block w-8 text-blue-300" title="nb_memos"><%= project.nb_memos %></span>
                        </td>
                        <td class="group p-1">
                            <%= link to: Routes.admin_organization_path(@conn, :show, project.organization), class: "underline" do %>
                                <%= img_tag(project.organization.logo, class: "inline-block h-4 w-4 rounded-md") %>
                                <%= project.organization.name %>
                            <% end %>
                            <%= render AzimuttWeb.PartialsView, "_page_filter.html", page: @projects, key: "organization_id", value: project.organization_id %>
                        </td>
                        <td class="group p-1">
                            <%= project.storage_kind %>
                            <%= render AzimuttWeb.PartialsView, "_page_filter.html", page: @projects, key: "storage_kind", value: project.storage_kind |> Atom.to_string() %>
                        </td>
                        <td class="group p-1">
                            <%= project.visibility %>
                            <%= render AzimuttWeb.PartialsView, "_page_filter.html", page: @projects, key: "visibility", value: project.visibility |> Atom.to_string() %>
                        </td>
                        <td class="group p-1" title={"Created on #{format_datetime(project.updated_at)}"}>
                            <%= format_datetime(project.updated_at) %>
                            <%= render AzimuttWeb.PartialsView, "_page_filter.html", page: @projects, key: "updated_at", value: format_date_filter(project.updated_at) %>
                        </td>
                    </tr>
                <% end %>
            </tbody>
        </table>
    </div>

    <%= render AzimuttWeb.PartialsView, "_pagination.html", page: @projects %>
</div>
